// index.js
// 引入store和操作store的库
import {createStoreBindings} from "mobx-miniprogram-bindings"
import {store} from "../../store/store"

Page({
  data: {

  },
  onLoad:function(){//生命周期函数--监听页面加载
      // 把store中的数据挂载到自身的this.storeBindings
        this.storeBindings = createStoreBindings(this,{
          store,
          fields:["numA","numB","sum"],
          actions:["updateNum1"]
        })
    },
    onUnload:function(){ //生命周期函数--监听页面卸载
      //卸载页面之前把收到的store库全都清理掉
        this.storeBindings.destoryStoreBindings()
    },
    // 自定义事件
    btnHandler1(e){
      this.updateNum1(e.target.dataset.step)
    },
  async getInfo(){
    // 调用promise化之后的异步API
    const {data:res} = await wx.p.request({
      url: 'https://applet-base-api-t.itheima.net/api/get',
      method:"GET",
      data:{
        name:'zs',
        age:'20'
      }
    })
    console.log(res);
  }
})
